<template>
	<!-- 开票流程表单 -->
	<view class="container">
		<u-form :model="form" ref="uForm" label-width="200">
		  <u-form-item label="任务名称"
		    ><u-input v-model="form.name" disabled
		  /></u-form-item>
		  <u-form-item label="所属流程"
		    ><u-input v-model="form.belong" disabled
		  /></u-form-item>
		  <u-form-item label="开票单位"
		    ><u-input v-model="formData.invoiceName" disabled
		  /></u-form-item>
		  <u-form-item label="收票单位"
		    ><u-input v-model="formData.collectionCcName" disabled
		  /></u-form-item>
		  <u-form-item label="委托人"
		    ><u-input v-model="form.client" disabled
		  /></u-form-item>
		  <u-form-item label="流程发起人"
		    ><u-input v-model="form.initiator" disabled
		  /></u-form-item>
		  <u-form-item label="优先级"
		    ><u-input v-model="form.priority" disabled class="input-color"
		  /></u-form-item>
		  <u-form-item label="状态"
		    ><u-input v-model="form.status" disabled
		  /></u-form-item>
		  <u-form-item label="纳税人识别号码">
		    <u-input v-model="formData.invoiceNumber" disabled/>
		  </u-form-item>
		  <u-form-item label="预计送票时间">
		    <u-input v-model="formData.invoiceDate" disabled/>
		  </u-form-item>
		  <u-form-item label="所属合同">
		    <u-input v-model="formData.contractName" disabled/>
		  </u-form-item>
		  <u-form-item label="开票金额">
		  	<u-input v-model="formData.invoiceAmount" disabled
		  /></u-form-item>
		  <u-form-item label="开票说明">
			<u-input v-model="formData.invoiceRemark" disabled
		  /></u-form-item>
		  <u-form-item label="创建时间">
		    <u-input v-model="form.time" disabled />
		  </u-form-item>
		</u-form>
	</view>
</template>

<script>
	import auditApi from "../../api/audit.js";
	import getNameApi from "../../api/getName.js";
	export default {
		name:"reimbursement",
		props:['form'],
		data() {
			return {
				formData:{
					invoiceAmount:0,
					invoiceRemark:'无',
					invoiceNumber:0,
					invoiceName:'无',
					collectionCcName:'无',
					contractName:'无',
					invoiceDate:'无'
				}
			};
		},
		mounted() {
			setTimeout(()=>{
				this.getData()
			},0)
		},
		methods:{
			async getData(){
				const res1 = await auditApi.getAuditDetail(
					{"X-Access-Token": this.$store.state.token},
					this.form.table)
				let {
				  invoiceAmount,
				  invoiceName,//开票单位,
				  collectionCcId,//收票单位
				  invoiceRemark,
				  contractId,
				  invoiceNumber,
				  invoiceDate,
				} = res1.data.result;
				this.formData.invoiceNumber = invoiceNumber
				this.formData.invoiceAmount = invoiceAmount
				this.formData.invoiceRemark = invoiceRemark
				this.formData.invoiceDate = invoiceDate
				//通过id查询单位名称
				  if(invoiceName){
					const res2 = await getNameApi.getCompanyName(
						{
						  "X-Access-Token": this.$store.state.token,
						},
						{id:invoiceName}
					  )
					  this.formData.invoiceName = res2.data.result.name
				  }
				  if(collectionCcId){
					const res2 = await getNameApi.getCompanyName(
						{
						  "X-Access-Token": this.$store.state.token,
						},
						{id:collectionCcId}
					  )
					  this.formData.collectionCcName = res2.data.result.name
				  }
				//通过id查询获取合同名称
				  if(contractId){
					const res2 = await getNameApi.getContractName(
						{
						  "X-Access-Token": this.$store.state.token,
						},
						{id:contractId}
					  )
					  this.formData.contractName = res2.data.result.contractName
				  }
			}
		}
	}
</script>

<style scoped lang="scss">
.container {
  width: 90%;
  margin: 0 auto;
}
</style>